home *** CD-ROM | disk | FTP | other *** search
- ;void char_box(ch,col,row,width,depth,color);
- ; unsigned char ch,col,row,width,depth,color;
-
-
- EXTRN _memory_model:byte
- EXTRN _video_buffer:word
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _char_box
- _char_box proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: cld ;set direction flag
- mov ax,_video_buffer ;fetch _video_buffer
- mov es,ax ;ES pts to screen
- mov si,bx ;procedure addr to SI
- sub ax,ax ;
- mov al,[bp+8] ;get row
- dec ax ;count from 0
- mov dl,160 ;bytes in a row
- mul dl ;times rows
- sub dx,dx ;
- mov dl,[bp+6] ;get column
- dec dx ;count from 0
- shl dx,1 ;double for attributes
- add ax,dx ;add to row offset
- mov di,ax ;ES:DI pts to first char
- sub bx,bx ;
- mov bl,[bp+10] ;width in BX
- or bx,bx ;test for zero
- jz L6 ;quit if zero
- sub dx,dx ;
- mov dl,[bp+12] ;depth in DX
- or dx,dx ;test for zero
- jz L6 ;quit if zero
- mov al,[bp+4] ;char in AL
- mov ah,[bp+14] ;attribute in AH
- L1: mov cx,bx ;width to CX as counter
- push di ;save starting point
- push dx ;save depth counter
- L2: cmp _snow_protect,0 ;protect against snow?
- je L5 ;jump ahead if not
- mov dx,3dah ;status byte address
- mov si,ax ;save AX contents
- L3: in al,dx ;get status byte
- test al,1 ;test bit
- jnz L3 ;loop till 0
- cli ;disable interrupts
- L4: in al,dx ;get status byte
- test al,1 ;test bit
- jz L4 ;loop till 1
- mov ax,si ;restore AX contents
- L5: stosw ;write char and attribute
- loop L2 ;go do next
- pop dx ;restore depth counter
- pop di ;restore starting point
- add di,160 ;forward ptr one row
- dec dx ;dec row counter
- jnz L1 ;go do next row
- L6: sti ;reenable interrupts
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _char_box endp
- _TEXT ENDS
- END